import {BasicColumn, FormSchema} from '/@/components/Table';

export const columns : BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'name',
    width: 100,
    align: 'left'
  },
  {
    title: '排序',
    dataIndex: 'sortNo',
    width: 80,
  },
  {
    title: '创建时间',
    dataIndex: 'createdAt',
    width: 160,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '名称',
    component: 'Input',
  },
];


export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    field: 'name',
    label: '分组名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'code',
    label: '组编码',
    component: 'Input',
    required: false,
  },
  {
    field: 'parentId',
    label: '上级分组',
    component: 'TreeSelect',
    required: false,
    ifShow: ({ model, field }) => model['isTree'], 
    componentProps: {
      fieldNames: {
        title: 'name',
        key: 'id',
        value: 'id',
      },
      dropdownStyle: {
        maxHeight: '60vh'
      },
      getPopupContainer: (node) => node.parentNode
    },
  },
  {
    field: 'sortNo',
    label: '排序',
    required: true,
    component: 'InputNumber',
    defaultValue: 1
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    componentProps: {
      autoSize: {
        minRows: 3,
        maxRows: 8
      }
    }
  },
];

